﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AUV5.Web.Pages
{
    public partial class UserFavorite : PageBaseFrontend
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (base.IsVerified)
                {
                    bindFavorite();    
                }
                else
                {
                    Response.Redirect(URL_INDEX);
                }
                
            }
        }

        private void bindFavorite()
        {
            Model.NetPager pager = new Model.NetPager();
            pager.TableName = "Favorite";
            pager.PrimaryKey = "FavoriteID";
            pager.PageSize = AspNetPager1.PageSize;
            pager.PageIndex = AspNetPager1.CurrentPageIndex;
            pager.Order = "CreateDate desc,FavoriteID asc";
            pager.SortType = (int)Common.Enum.SortType.Multi;
            pager.Where = "UserID='" + base.VerifiedUserID+"'";

            IList<Model.ServiceInfo> list = BLL.FavoriteBLL.Instance.GetPagedFavoriteServiceList(pager);
            //UCServiceList1.UserID = base.VerifiedUserID;
            UCServiceList1.Bind(list);

            AspNetPager1.RecordCount = pager.TotalCount;
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            bindFavorite();
        }
    }
}